$(document).ready(function () {
    $('.multiselect').multiselect({
        buttonWidth: 'auto',
        buttonText: function (options) {
            if (options.length == 0) {
                return '请选择';
            } else {
                var selected = '';
                options.each(function () {
                    selected += $(this).text() + ',';
                });
                return selected.substr(0, selected.length - 1);
            }
        },
    });
});

function saveHtml() {
    let webpage = $("#downloadModal textarea").val();
    console.log(webpage);
    if (navigator.appName == "Microsoft Internet Explorer"
        && window.ActiveXObject) {
        var locationFile = location.href.toString();
        var dlg = false;
        with (document) {
            ir = createElement('iframe');
            ir.id = 'ifr';
            ir.location = 'about.blank';
            ir.style.display = 'none';
            body.appendChild(ir);
            with (getElementById('ifr').contentWindow.document) {
                open("text/html", "replace");
                charset = "gbk";
                write(webpage);
                close();
                document.charset = "gbk";
                dlg = execCommand('SaveAs', false, locationFile
                    + "template.html");
            }
            return dlg;
        }
    } else {
        webpage = webpage;
        var blob = new Blob([webpage], {
            type: "text/html;charset=gbk"
        });
        saveAs(blob, "template.html");
    }
}